package com.github.config;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.system.SystemUtil;
import lombok.Data;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.boot.context.properties.ConfigurationProperties;

/**
 * @author 陈敏
 * @version WebServerProperties.java, v 1.1 2021/5/26 23:14 chenmin Exp $
 * Created on 2021/5/26
 */
@Data
@ConfigurationProperties(prefix = "webserver")
public class WebServerProperties implements InitializingBean {

    private String jsonPath;

    @Override
    public void afterPropertiesSet() throws Exception {
        if (ObjectUtil.isEmpty(jsonPath)) {
            String homeDir = SystemUtil.getUserInfo().getHomeDir();
            jsonPath = homeDir + StrUtil.BACKSLASH + "db.json";
        }
    }
}
